<template>
    <div>
      <!-- 综合查询
      <div>
<el-form :inline="true"  class="demo-form-inline">
  <el-form-item label="任务名称">
    <el-input v-model="sname" placeholder="任务名称"></el-input>
  </el-form-item>
   <el-form-item label="创建时间">
  <el-date-picker
      v-model="value1"
      type="date"
      placeholder="选择日期">
    </el-date-picker>
    </el-form-item>
  <el-form-item>
    <el-button type="primary"  icon="el-icon-search" @click="onSubmit">搜索</el-button>
      <el-button type="primary" icon="el-icon-check" @click="dialogFormVisible = true">批量通过</el-button> 
      
  </el-form-item>
</el-form>
      </div> -->

       <!-- 添加页面
<div>
<el-dialog title="批量通过" :visible.sync="dialogFormVisible">
  <el-form :model="ruleForm" >
 <el-form-item label="审批意见" prop="age" :label-width="formLabelWidth">
    <el-input v-model="ruleForm.age" type="textarea"
  :rows="2"
  placeholder="请输入内容"></el-input>
  </el-form-item>
  <el-form-item label="消息通知" prop="sname" :label-width="formLabelWidth">
    <el-checkbox-group v-model="ruleForm.sname">
    <el-checkbox label="站内消息通知"></el-checkbox>
    <el-checkbox label="短信通知"></el-checkbox>
    <el-checkbox label="邮件通知"></el-checkbox>
  </el-checkbox-group>
  </el-form-item>
</el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="saveStudent()">确 定</el-button>
  </div>
</el-dialog>
</div> -->

  <!-- 修改页面-->
<!-- <div>
<el-dialog title="批量反驳" :visible.sync="dialogUpdateFormVisible">
  <el-form :model="updateForm" >
     <el-form-item label="审批" prop="sname" :label-width="formLabelWidth">
   <el-radio v-model="radio" label="1">通过</el-radio>
  <el-radio v-model="radio" label="2">驳回</el-radio>
  </el-form-item>
 <el-form-item label="审批意见" prop="age" :label-width="formLabelWidth">
    <el-input v-model="updateForm.age" type="textarea"
  :rows="2"
  placeholder="请输入内容"></el-input>
  </el-form-item>
</el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogUpdateFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="saveStudent()">确 定</el-button>
  </div>
</el-dialog>
</div>  -->
       <!-- 列表显示 -->
      <div>
         <el-table border ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"  @selection-change="handleSelectionChange">  
           
        <el-table-column  prop="daibanid" label="编号" width="120">
          <template slot-scope="{row}">
            <span>{{ row.daibanid }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="biaoti" label="作品名称" width="120">
            <template slot-scope="{row}">
              <span>{{ row.biaoti }}</span>
            </template>
        </el-table-column>

        <el-table-column prop="dbname" label="申请人" width="120">
            <template slot-scope="{row}">
              <span>{{ row.dbname }}</span>
            </template>
        </el-table-column>

        <el-table-column prop="reason" label="作品说明" width="120">
            <template slot-scope="{row}">
              <span>{{ row.reason }}</span>
            </template>
        </el-table-column>

        <el-table-column prop="jdname"  label="当前审批节点" width="120">
            <template slot-scope="{row}">
              <span>{{ row.jdname }}</span>
            </template>
        </el-table-column>

         <el-table-column prop="zuopinmingci" label="作品名次" :formatter="mingci" width="120"></el-table-column>
        <el-table-column prop="zuopinjiangjin" label="作品奖金" :formatter="jiangjin" width="120"></el-table-column>

        <el-table-column prop="createtime" label="提交申请时间" width="180">
        <template slot-scope="scope">{{ scope.row.createtime }}</template>
        </el-table-column>
          
        <el-table-column label="审批状态" prop="states" :formatter="zhuangtai" width="162" />

        <el-table-column fixed="right" label="操作" width="220">
          <template slot-scope="scope">
            <el-button type="text"  @click='shenpi(scope.row)'  v-if="scope.row.states==1 || scope.row.states==2" >作品审批</el-button>
            <el-button type="text"  @click='banjiang(scope.row)' v-if=" scope.row.states==4 || scope.row.states==5 "  >颁奖审批</el-button>
            <el-button type="text"  @click='paiming(scope.row)'  v-if=" scope.row.states==6 || scope.row.states==7 " >名次审批</el-button>
            <el-button type="text" @click="bohui(scope.row)">驳回</el-button>
          </template>
        
      </el-table-column>
      
  </el-table>
  <br>
  <!-- <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[5, 10, 20, 50]"
      :page-size="5"
      layout="total, sizes, prev, pager, next, jumper"
      :total="5">
    </el-pagination> -->
    </div>
    </div>
</template>
<script>
import { querytask,mycomplete} from "@/api/wodedaiban"; 
import {exclusivemycomplete, deleteComplete,parallermycomplete} from "@/api/activiti";
export default {
    data() {
        return {
         // radio: '1',
          //name:"",
        tableData: [],
        multipleSelection: [],
        // currentPage4: 4,
        // value1:"",
        // formLabelWidth: '100px',
        // dialogUpdateFormVisible:false,       
        // updateForm:{
        //  sname:'',
        //  age:'',
        //     }
      }
    },
     created() {
    this.getList();
  },
  methods: {
     jiangjin: function(row, column) {
      return row.zuopinjiangjin == "0"
        ? "未获奖"
        : row.zuopinjiangjin == "50000"
        ? "一等奖(伍万元)"
        : row.zuopinjiangjin == "30000"
        ? "二等奖(叁万元)"
        : row.zuopinjiangjin == "10000"
        ? "三等奖(壹万元)"
        : "";
    },

    mingci: function(row, column) {
      return row.zuopinmingci == "0"
        ? "未排名"
        : row.zuopinmingci == "1"
        ? "第一名"
        : row.zuopinmingci == "2"
        ? "第二名"
        : row.zuopinmingci == "3"
        ? "第三名"
        : "";
    },
      zhuangtai: function(row, column) {
      return row.states == "0"
        ? "未审批"
        : row.states == "1"
        ? "审批中"
        : row.states == "3"
        ? "审批不通过"
        : row.states == "2"
        ? "审批完成"
        : row.states == "4"
        ? "奖励发放中"
        : row.states == "5"
        ? "奖励发放完毕"
        :row.states == "6"
        ? "排名中"
         :row.states == "7"
        ? "排名完成"
        :"";
    },
    getList() {    
      this.listLoading = false
      //this.ee=JSON.parse(sessionStorage.getItem('user'))
     // console.log(this.ee)
      //console.log()
      // console.log(this.ee[0].userName)
       let username=sessionStorage.getItem("username");
        console.log(username);
      querytask(this.tableData,username).then(response => {  
        console.log("账号："+username);
         // console.log("当前登录人："+sessionStorage.getItem("nickName"));
          console.log("------");
          console.log(response.data)
          this.tableData = response.data
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
   //点击审批按钮
      shenpi(row){
        console.log("---"+row.daibanid);
        mycomplete(row.daibanid).then(response => {
          alert("审批成功")
          console.log("++++"+response.data);
          setTimeout(() => {
            this.listLoading = false
          }, 5 * 1000)
        })
      },
       //排他网关
      banjiang(row){
          let num=sessionStorage.getItem("num");
          console.log("当前作品奖金："+num);
          console.log("实例id："+row.daibanid);
          exclusivemycomplete(row.daibanid,num).then(response => {
          alert("颁发通过")
          console.log("++++"+response.data);
          setTimeout(() => {
            this.listLoading = false
          }, 5 * 1000)
        })
      },
       //并行网关 点击排名审核按钮
      paiming(row){
          let mingci=sessionStorage.getItem("mingci");
          let username=sessionStorage.getItem("username");
          console.log("作品名次："+mingci);
          console.log("实例id："+row.daibanid);
          parallermycomplete(row.daibanid,mingci,username).then(response => {
          alert("排名审核成功")
          
          setTimeout(() => {
            this.listLoading = false
          }, 5 * 1000)
        })
      },
      //驳回
      bohui(row){
        console.log("---"+row.daibanid);
        deleteComplete(row.daibanid).then(response => {
          alert("已驳回")
          console.log("++++"+response.data);
          setTimeout(() => {
            this.listLoading = false
          }, 5 * 1000)
        })
      },
    
}
}
              
</script>